// $Id$

#include "PreCompile.h"
#include "IoCpp/Configuration.h"
#include "IoCpp/Detail/ConfigRegistry.h"

#include <algorithm>


using namespace IoCpp;
using namespace IoCpp::Detail;


void ConfigRegistry::AddConfiguration( ConfigProvider provider ) {
   providers.push_back(provider);
}


void ConfigRegistry::Configure( Configuration& config ) const
{
   class ConfigCommit
   {
   public :
      ConfigCommit( Configuration& config )
         : config(config) {
      }

      void operator()( ConfigProvider provider ) const {
         provider(config);
      }

   private :
      Configuration& config;
   };

   std::for_each(providers.begin(), providers.end(), ConfigCommit(config));
}
